package com.molichuxing.services.exception;

import java.util.HashMap;
import java.util.Map;

public enum OrderExceptionCodeEnum {
	/**
	 * 数据不存在
	 */
	NOT_EXIST(20401, "数据不存在"),
	/**
	 * 参数不能为空
	 */
	NOT_EMPTY(20402, "参数不能为空"),
	/**
	 * 已还款
	 */
	ALREADY(20403, "已还款"),
	/**
	 * 状态错误
	 */
	STATUS_ERROR(20404, "状态错误"),
	/**
	 * 操作失败
	 */
	ERROR(20405, "操作失败");

	final static private Map<Integer, OrderExceptionCodeEnum> MAP = new HashMap<Integer, OrderExceptionCodeEnum>() {
		private static final long serialVersionUID = -8414553247670306999L;
		{
			OrderExceptionCodeEnum[] enums = OrderExceptionCodeEnum.values();
			for (OrderExceptionCodeEnum OrderExceptionCodeEnum : enums) {
				put(OrderExceptionCodeEnum.getCode(), OrderExceptionCodeEnum);
			}
		}
	};

	public static OrderExceptionCodeEnum getEnum(Integer code) {
		return MAP.get(code);
	}

	public static String getEnumDesc(Integer code) {
		OrderExceptionCodeEnum OrderExceptionCodeEnum = MAP.get(code);
		if (OrderExceptionCodeEnum != null) {
			return OrderExceptionCodeEnum.getMessage();
		}
		return "";
	}

	private Integer code;

	private String message;

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	private OrderExceptionCodeEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
}
